Hello,
what will be the regular expression for (($any number)any string) and path for eg:path:/any string/any string/any string/any string with square bracket
i write regular expression (\(\$\d\)+ .*)for first but its not working.
please help me out
Thanks in advance
Regards,
Hemlata
SystemAdmin - Tue Mar 19 02:24:59 EDT 2013 |
|
Re: Regular expression Mathias Mamsch - Tue Mar 19 04:20:16 EDT 2013
The DOORS regexp engine does not support the normal "\d" for digits. You have to use "http://0-9a-zA-Z_./" or something like this to define ranges. Regards, Mathias
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
|
Re: Regular expression Mathias Mamsch - Tue Mar 19 04:21:41 EDT 2013 Mathias Mamsch - Tue Mar 19 04:20:16 EDT 2013
The DOORS regexp engine does not support the normal "\d" for digits. You have to use "http://0-9a-zA-Z_./" or something like this to define ranges. Regards, Mathias
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
Whoops I fell for the bracket thing. Here it goes again:
The DOORS regexp engine does not support the normal "\d" for digits. You have to use "[0-9a-zA-Z_./]+" or something like this to define character ranges. Regards, Mathias
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
|
Re: Regular expression SystemAdmin - Tue Mar 19 04:56:32 EDT 2013 Mathias Mamsch - Tue Mar 19 04:21:41 EDT 2013
Whoops I fell for the bracket thing. Here it goes again:
The DOORS regexp engine does not support the normal "\d" for digits. You have to use "[0-9a-zA-Z_./]+" or something like this to define character ranges. Regards, Mathias
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
Hello Mathias,
thanks for replying. (\(\$0-9\)^;*) i wrote this patter but it is also not working in DOORS. i am not getting what is the problem.
Regards,
Hemlata
|
|
Re: Regular expression SystemAdmin - Tue Mar 19 04:59:54 EDT 2013 SystemAdmin - Tue Mar 19 04:56:32 EDT 2013
Hello Mathias,
thanks for replying. (\(\$0-9\)^;*) i wrote this patter but it is also not working in DOORS. i am not getting what is the problem.
Regards,
Hemlata
Hey
that is not pasted properly. (\(\$0-9\) ^ ; *) this is correct one. may be some problem happend with editor.
|
|
Re: Regular expression Mathias Mamsch - Tue Mar 19 05:40:15 EDT 2013 SystemAdmin - Tue Mar 19 04:59:54 EDT 2013
Hey
that is not pasted properly. (\(\$0-9\) ^ ; *) this is correct one. may be some problem happend with editor.
For using square brackets in the text you need to use one backslash before the opening bracket: [] otherwise it will be treated as a link
\[This will be displayed with square brackets in the text]
Can you paste the complete example, with some example strings where you want to apply the regular expression to. This will clear up, why it is not working.
Regards, Mathias
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
|
Re: Regular expression SystemAdmin - Tue Mar 19 06:02:11 EDT 2013 Mathias Mamsch - Tue Mar 19 05:40:15 EDT 2013
For using square brackets in the text you need to use one backslash before the opening bracket: [] otherwise it will be treated as a link
\[This will be displayed with square brackets in the text]
Can you paste the complete example, with some example strings where you want to apply the regular expression to. This will clear up, why it is not working.
Regards, Mathias
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
For Eg: string is ($56)SourceCode
Now i need to write regular expression pattern for above string. Number 56 and string SourceCode is varing depends on requirement
for that i write (\(\$0-9+\)+[^;]*)
|
|
Re: Regular expression Mathias Mamsch - Tue Mar 19 06:21:13 EDT 2013 SystemAdmin - Tue Mar 19 06:02:11 EDT 2013
For Eg: string is ($56)SourceCode
Now i need to write regular expression pattern for above string. Number 56 and string SourceCode is varing depends on requirement
for that i write (\(\$0-9+\)+[^;]*)
You need to be aware that a backslash in a string also needs to be escaped. So you would need something like:
Regexp re = regexp2 "\\(($[0-9]+)\\)[^;]*"
Buffer buf = create()
buf = "($56)SourceCode;Text;($128)SomeMore;"
int pos = 0;
while (search(re, buf, pos)) {
string sWholeMatch = buf[pos+start 0:pos+end 0]
string sMatchGroup1 = buf[pos+start 1:pos+end 1]
print "Whole match: " sWholeMatch " Number: " sMatchGroup1 "\n"
pos += end 0
}
Regards, Mathias
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
|
Re: Regular expression SystemAdmin - Tue Mar 19 07:01:21 EDT 2013 Mathias Mamsch - Tue Mar 19 06:21:13 EDT 2013
You need to be aware that a backslash in a string also needs to be escaped. So you would need something like:
Regexp re = regexp2 "\\(($[0-9]+)\\)[^;]*"
Buffer buf = create()
buf = "($56)SourceCode;Text;($128)SomeMore;"
int pos = 0;
while (search(re, buf, pos)) {
string sWholeMatch = buf[pos+start 0:pos+end 0]
string sMatchGroup1 = buf[pos+start 1:pos+end 1]
print "Whole match: " sWholeMatch " Number: " sMatchGroup1 "\n"
pos += end 0
}
Regards, Mathias
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
Thanks a lot.
Its working. but I don't understand, why we didn't escape $?
Regards,
Hemlata
|
|
Re: Regular expression Mathias Mamsch - Tue Mar 19 07:28:47 EDT 2013 SystemAdmin - Tue Mar 19 07:01:21 EDT 2013
Thanks a lot.
Its working. but I don't understand, why we didn't escape $?
Regards,
Hemlata
We did not escape the dollar, because it is not a special character in DOORS regexp engine. Only . + * \ [ ] { } ~ are supported by DOORS regexp engine and therefore I would think you only need to escape those. Inside of square brackets (character range) you even do not need to escape those except the closing brace ]. Is $ even a special character in other regexp engines? However I am not sure if this 100% applies to the regexp2, which might have additional capabilities I never tried ... Regards, Mathias
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
|
Re: Regular expression Mathias Mamsch - Tue Mar 19 07:31:40 EDT 2013 Mathias Mamsch - Tue Mar 19 07:28:47 EDT 2013
We did not escape the dollar, because it is not a special character in DOORS regexp engine. Only . + * \ [ ] { } ~ are supported by DOORS regexp engine and therefore I would think you only need to escape those. Inside of square brackets (character range) you even do not need to escape those except the closing brace ]. Is $ even a special character in other regexp engines? However I am not sure if this 100% applies to the regexp2, which might have additional capabilities I never tried ... Regards, Mathias
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
Ups, in the above the curly brackets should be replaced by round brackets: . + * \ [ ] ( ) ~ . Curly brackets are not supported, as far as I know. Another note: From my experience it does not hurt to escape other special characters, the regular expression will ignore the backslash. Note that for a literal backslash in DXL regexp you need four backslashes: \\\\
Regards, Mathias
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
|
Re: Regular expression SystemAdmin - Tue Mar 19 07:52:17 EDT 2013 Mathias Mamsch - Tue Mar 19 07:31:40 EDT 2013
Ups, in the above the curly brackets should be replaced by round brackets: . + * \ [ ] ( ) ~ . Curly brackets are not supported, as far as I know. Another note: From my experience it does not hurt to escape other special characters, the regular expression will ignore the backslash. Note that for a literal backslash in DXL regexp you need four backslashes: \\\\
Regards, Mathias
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
OK..Thank you very much Mathias. Information that you have provided is very much helpfull to me and will help in future also.
Once again thank you.
Regards,
Hemlata
|
|